<?php
include 'test_header.php';
class test_db_obj_result extends UnitTestCase{	

	function setUp(){
		$db = db_connect();

		$sql = "
CREATE TABLE IF NOT EXISTS `result` (
`code_file_name` varchar(64) NOT NULL,
`judge_time` datetime NOT NULL,
  `problem_no` int(11) NOT NULL,
  `username` varchar(256) NOT NULL,
  `result` varchar(1024) NOT NULL,
  `time_spend` varchar(128) NOT NULL,
  `memory_spend` varchar(128) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
" ;
		$res = $db->query( $sql );
	}
	
	function tearDown(){

		$db = db_connect();

		$sql = "drop table code";

		$res = $db->query( $sql );
	}

	function test_save_judge_result(){

		$db = db_connect();

		$db_obj_result = new db_obj_result( $db ) ;


		$db_obj_result->set( 'code_file_name' , 'test.c' );
		$db_obj_result->set( 'judge_time' , date( 'N-m-d H-m-s') );
		$db_obj_result->set( 'problem_no' , '1000' );
		$db_obj_result->set( 'username' , 'tester' );
		$db_obj_result->set( 'result' , 'ac' );
		$db_obj_result->set( 'time_spend' , '1001' );
		$db_obj_result->set( 'memory_spend' , '1024' );

		$this->assertTrue( $db_obj_result->save() );

		$db_obj_result_1 = new db_obj_result( $db ) ;

		//是否要重写load才能查询双主键的表
	}

}


$test = new test_db_obj_result();
$test->run( new HtmlReporter() );




